package com.bite.springblog.pojo.response;

import com.bite.springblog.enums.ResultEnums;
import lombok.Data;

@Data
public class Result {
    private Integer code;
    private String errMge;
    private Object data;

    public static Result success(Object data){
        Result result = new Result();
        result.setData(data);
        result.setCode(ResultEnums.SUCCESS.getCode());
        return result;
    }

    public static Result fail(String errMge){
        Result result = new Result();
        result.setErrMge(errMge);
        result.setCode(ResultEnums.FAIL.getCode());
        return result;
    }

    public static Result fail(String errMge,Object data){
        Result result = new Result();
        result.setData(data);
        result.setErrMge(errMge);
        result.setCode(ResultEnums.FAIL.getCode());
        return result;
    }
}
